/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.component.feedback.domain;

import cn.hutool.core.bean.BeanUtil;
import info.peigen.hotpot.common.core.domain.DomainObject;
import info.peigen.hotpot.common.core.order.Order;
import info.peigen.hotpot.common.service.base.processor.ProcessorServiceContext;
import info.peigen.hotpot.component.feedback.service.enums.FeedbackType;
import info.peigen.hotpot.component.feedback.service.order.FeedbackCreateOrder;
import lombok.*;
import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;
import lombok.experimental.SuperBuilder;

import java.util.List;

/**
 * <b>(Feedback)</b>
 * 反馈建议
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2022/11/18
 */
@EqualsAndHashCode(callSuper = true)
@SuperBuilder
@Data
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
@Accessors(chain = true)
public class Feedback extends DomainObject {
    String customerId;
    @Builder.Default
    FeedbackType type = FeedbackType.Feedback;
    /** 反馈内容 */
    String       context;
    List<String> images;

    public static Feedback init(Order order) {
        return BeanUtil.toBean(order, Feedback.class);
    }

    public static Feedback create(ProcessorServiceContext context) {
        FeedbackCreateOrder order = (FeedbackCreateOrder) context.getOrder();
        return BeanUtil.copyProperties(order, Feedback.class);
    }
}